package com.ruoyi.eduadmin.controller;

import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.web.page.TableDataInfo;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.eduadmin.domain.TStudentTask;
import com.ruoyi.eduadmin.service.ITStudentTaskService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 【请填写功能名称】Controller
 * 
 * @author ruoyi
 * @date 2022-12-31
 */
@RestController
@RequestMapping("/task")
public class TStudentTaskController extends BaseController
{
    @Autowired
    private ITStudentTaskService tStudentTaskService;

    /**
     * 查询【请填写功能名称】列表
     */
    @RequiresPermissions("eduadmin:task:list")
    @GetMapping("/list")
    public TableDataInfo list(TStudentTask tStudentTask)
    {
        startPage();
        List<TStudentTask> list = tStudentTaskService.selectTStudentTaskList(tStudentTask);
        return getDataTable(list);
    }

    /**
     * 导出【请填写功能名称】列表
     */
    @RequiresPermissions("eduadmin:task:export")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TStudentTask tStudentTask)
    {
        List<TStudentTask> list = tStudentTaskService.selectTStudentTaskList(tStudentTask);
        ExcelUtil<TStudentTask> util = new ExcelUtil<TStudentTask>(TStudentTask.class);
        util.exportExcel(response, list, "【请填写功能名称】数据");
    }

    /**
     * 获取【请填写功能名称】详细信息
     */
    @RequiresPermissions("eduadmin:task:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(tStudentTaskService.selectTStudentTaskById(id));
    }

    /**
     * 新增【请填写功能名称】
     */
    @RequiresPermissions("eduadmin:task:add")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TStudentTask tStudentTask)
    {
        return toAjax(tStudentTaskService.insertTStudentTask(tStudentTask));
    }

    /**
     * 修改【请填写功能名称】
     */
    @Log(title = "【请填写功能名称】", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TStudentTask tStudentTask)
    {
        return toAjax(tStudentTaskService.updateTStudentTask(tStudentTask));
    }

    /**
     * 删除【请填写功能名称】
     */
    @Log(title = "【请填写功能名称】", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tStudentTaskService.deleteTStudentTaskByIds(ids));
    }

    @GetMapping("/list/{id}")
    public List<TStudentTask> findTaskListByStudentId(@PathVariable Long id)
    {
        List<TStudentTask> list = tStudentTaskService.findTaskListByStudentId(id);
        return list;
    }


}
